<?php

/**
 * webconfigs actions.
 *
 * @package    cms
 * @subpackage webconfigs
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class WebConfigsActions extends sfActions
{

  public function executeIndex(sfWebRequest $request)
  {

    $web_configs = Doctrine::getTable('WebConfigs')->createQuery()->orderBy('created_at desc')->fetchOne();

    $this->form = new WebConfigsForm($web_configs);
    
    if($request->isMethod('POST'))
    {
        $this->processForm($request, $this->form);
    }
  }
  
  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));

    if ($form->isValid())
    {
      if($form->save())
      {
        $this->getUser()->setFlash('notice', '配置信息保存成功');
      }
      $this->redirect('webconfigs/index');
    }
  }
//
//  public function executeShow(sfWebRequest $request)
//  {
//    $this->web_configs = Doctrine::getTable('WebConfigs')->find(array($request->getParameter('id')));
//    $this->forward404Unless($this->web_configs);
//  }
//
//  public function executeNew(sfWebRequest $request)
//  {
//    $this->form = new WebConfigsForm();
//  }
//
//  public function executeCreate(sfWebRequest $request)
//  {
//    $this->forward404Unless($request->isMethod(sfRequest::POST));
//

//    $this->form = new WebConfigsForm();
//
//    $this->processForm($request, $this->form);
//
//    $this->setTemplate('new');
//  }
//
//  public function executeEdit(sfWebRequest $request)
//  {
//    $this->forward404Unless($web_configs = Doctrine::getTable('WebConfigs')->find(array($request->getParameter('id'))), sprintf('Object web_configs does not exist (%s).', $request->getParameter('id')));
//    $this->form = new WebConfigsForm($web_configs);
//  }
//
//  public function executeUpdate(sfWebRequest $request)
//  {
//    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
//    $this->forward404Unless($web_configs = Doctrine::getTable('WebConfigs')->find(array($request->getParameter('id'))), sprintf('Object web_configs does not exist (%s).', $request->getParameter('id')));
//    $this->form = new WebConfigsForm($web_configs);
//
//    $this->processForm($request, $this->form);
//
//    $this->setTemplate('edit');
//  }
//
//  public function executeDelete(sfWebRequest $request)
//  {
//    $request->checkCSRFProtection();
//
//    $this->forward404Unless($web_configs = Doctrine::getTable('WebConfigs')->find(array($request->getParameter('id'))), sprintf('Object web_configs does not exist (%s).', $request->getParameter('id')));
//    $web_configs->delete();
//
//    $this->redirect('webconfigs/index');
//  }
//

}
